BaseWellItem.prototype = {
__proto__: AppIcon.AppIcon.prototype,
- _init: function(appInfo, isFavorite, hasMenu) {
- AppIcon.AppIcon.prototype._init.call(this, appInfo, hasMenu ? AppIcon.MenuType.ON_RIGHT : AppIcon.MenuType.NONE, true);
+ _init: function(appInfo, isFavorite) {
+ AppIcon.AppIcon.prototype._init.call(this, appInfo, AppIcon.MenuType.ON_RIGHT, true);
this.isFavorite = isFavorite;
__proto__: BaseWellItem.prototype,
_init: function(appInfo, isFavorite) {
- BaseWellItem.prototype._init.call(this, appInfo, isFavorite, true);
+ BaseWellItem.prototype._init.call(this, appInfo, isFavorite);
this._dragStartX = 0;
this._dragStartY = 0;
return true;
}
return false;
+ },
+
+ menuPoppedUp: function() {
+ },
+
+ menuPoppedDown: function() {
}
};
childBox.y2 = childBox.y1 + itemHeight;
children[i].allocate(childBox, flags);
- let atSeparator = (i == this._separatorIndex - 1);
-
columnIndex++;
- if (columnIndex == columns || atSeparator) {
+ if (columnIndex == columns) {
columnIndex = 0;
}
} else {
x += itemWidth;
}
-
- if (atSeparator) {
- y += separatorNatural + WELL_ITEM_VSPACING;
- }
}
-
- let separatorRowIndex = Math.ceil(this._separatorIndex / columns);
-
- /* Allocate the separator */
- let childBox = new Clutter.ActorBox();
- childBox.x1 = box.x1;
- childBox.y1 = (itemHeight + WELL_ITEM_VSPACING) * separatorRowIndex;
- this._cachedSeparatorY = childBox.y1;
- childBox.x2 = box.x2;
- childBox.y2 = childBox.y1+separatorNatural;
- this._separator.allocate(childBox, flags);
- },
-
- setSeparatorIndex: function (index) {
- this._separatorIndex = index;
- this.actor.queue_relayout();
},
removeAll: function () {
for (let i = 0; i < itemChildren.length; i++) {
itemChildren[i].destroy();
}
- this._separatorIndex = 0;
- },
-
- isBeforeSeparator: function(x, y) {
- return y < this._cachedSeparatorY;
},
_getItemChildren: function () {
let minWidth = itemMinWidth * nColumns;
let lastColumnIndex = nColumns - 1;
- let separatorColumns = lastColumnIndex - ((lastColumnIndex + this._separatorIndex) % nColumns);
- let rows = Math.ceil((children.length + separatorColumns) / nColumns);
+ let rows = Math.ceil(children.length / nColumns);
let itemWidth;
if (forWidth < 0) {
let displays = []
this._addApps(favorites, true);
- this._grid.setSeparatorIndex(favorites.length);
this._addApps(running, false);
this._displays = displays;
},
let appSystem = Shell.AppSystem.get_default();
let app = null;
- if (source instanceof BaseWellItem) {
- app = source.appInfo;
- } else if (source instanceof AppDisplayItem) {
+ if (source instanceof AppDisplayItem) {
app = appSystem.lookup_cached_app(source.getId());
} else if (source instanceof Workspaces.WindowClone) {
let appMonitor = Shell.AppMonitor.get_default();
let favoriteIds = this._appSystem.get_favorites();
let favoriteIdsObject = this._arrayValues(favoriteIds);
- let dropIsFavorite = this._grid.isBeforeSeparator(x - this._grid.actor.x,
- y - this._grid.actor.y);
let srcIsFavorite = (id in favoriteIdsObject);
- if (srcIsFavorite && (!dropIsFavorite)) {
- Mainloop.idle_add(function () {
- appSystem.remove_favorite(id);
- return false;
- });
- } else if ((!srcIsFavorite) && dropIsFavorite) {
+ if (srcIsFavorite) {
+ return false;
+ } else {
Mainloop.idle_add(function () {
appSystem.add_favorite(id);
return false;
});
- } else {
- return false;
}
return true;
let iconsDiffer = false;
let texCache = Shell.TextureCache.get_default();
- let firstIcon = windows[0].mini_icon;
- for (let i = 1; i < windows.length; i++) {
- if (!texCache.pixbuf_equal(windows[i].mini_icon, firstIcon)) {
- iconsDiffer = true;
- break;
+ if (windows.length > 0) {
+ let firstIcon = windows[0].mini_icon;
+ for (let i = 1; i < windows.length; i++) {
+ if (!texCache.pixbuf_equal(windows[i].mini_icon, firstIcon)) {
+ iconsDiffer = true;
+ break;
+ }
}
}
}
this._appendWindows(otherWorkspaceWindows, iconsDiffer);
- this._appendSeparator();
+ if (windows.length > 0)
+ this._appendSeparator();
+
+ this._newWindowMenuItem = windows.length > 0 ? this._appendMenuItem(null, _("New Window")) : null;
- this._newWindowMenuItem = this._appendMenuItem(null, _("New Window"));
+ let favorites = Shell.AppSystem.get_default().get_favorites();
+ let id = this._source.appInfo.get_id();
+ this._isFavorite = false;
+ for (let i = 0; i < favorites.length; i++) {
+ if (id == favorites[i]) {
+ this._isFavorite = true;
+ break;
+ }
+ }
+ if (windows.length > 0)
+ this._appendSeparator();
+ this._toggleFavoriteMenuItem = this._appendMenuItem(null, this._isFavorite ? _("Remove from favorites")
+ : _("Add to favorites"));
this._highlightedItem = null;
},
} else if (child == this._newWindowMenuItem) {
this._source.appInfo.launch();
this.emit('activate-window', null);
+ } else if (child == this._toggleFavoriteMenuItem) {
+ let appSys = Shell.AppSystem.get_default();
+ if (this._isFavorite)
+ appSys.remove_favorite(this._source.appInfo.get_id());
+ else
+ appSys.add_favorite(this._source.appInfo.get_id());
}
this.popdown();
},